#include <iostream>

using namespace std;

string test(string s, int k)
{

    for (int i = 0; i < s.size(); i += (2 * k))
    {

        if (i + k <= s.size())
        {
            reverse(s.begin() + i, s.begin() + i + k);
            continue;
        }

        reverse(s.begin() + i, s.begin() + s.size());
    }
    return s;

}


int main()
{
    string s("abcdefg");
    int k = 2;

    cout << test(s, k) << endl;
    return 0;
}